/**
 *
 */
package com.ybkj.daijia.server.service.impl;

import com.ybkj.daijia.common.Pager;
import com.ybkj.daijia.page.Page;
import com.ybkj.daijia.page.Pageable;
import com.ybkj.daijia.page.impl.PageImpl;
import com.ybkj.daijia.page.impl.PageRequest;
import com.ybkj.daijia.server.mapper.DjInsuranceMapper;
import com.ybkj.daijia.server.model.DjInsurance;
import com.ybkj.daijia.server.service.DjInsuranceService;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Shine
 *
 */
@Service
public class DefaultDjInsuranceService implements DjInsuranceService {

    @Autowired
    private DjInsuranceMapper djInsuranceMapper;


    @Transactional(rollbackFor = Exception.class)
    public DjInsurance insertRecord(DjInsurance djInsurance) {

        djInsuranceMapper.insertRecord(djInsurance);

        return djInsurance;
    }

    @Override
    public DjInsurance findOne(Long id) {

        return djInsuranceMapper.selectByPrimaryKey(id);
    }


    @Override
    public Page<DjInsurance> queryByParam(String type, Date start, Date end) {

        Pageable pageable = new PageRequest(Pager.getPage(), Pager.getLimit());

        List<DjInsurance> content = djInsuranceMapper
            .selectByParam(type, start, end, Pager.getOffset(), Pager.getLimit());
        long total = djInsuranceMapper.countByParam(type, start, end);

        return new PageImpl<DjInsurance>(content, pageable, total);
    }

    @Override
    public List<DjInsurance> listByParam(String type, Date start, Date end) {

        List<DjInsurance> content = djInsuranceMapper.selectByParam(type, start, end, null, null);

        return content;
    }

}
	
	
